// 从 ES6 模块中导入模块
// let m = null;
// (async () => {
//   m = await import("./foo.mjs");
// })()

// module.exports = {
//   ...m
// }


const fs = require('fs');
let MagnetLink = null;
let TorrentFile = null;

function decodeMaget(uri) {
    const parsed = MagnetLink.magnetDecode(uri);
    console.log(parsed)
}

function parseTorrentFile() {
    const torrentInfo = TorrentFile.info(fs.readFileSync('/Users/shanke/Downloads/[BTSCHOOL].[狙击手白乌鸦]Sniper.The.White.Raven.2022.BluRay.720p.x264.2Audios.AC3-BtsHD.mkv.torrent'));
    console.log({ torrentInfo });
}

;(async () => {
    MagnetLink = await import("@ctrl/magnet-link");
    TorrentFile = await import("@ctrl/torrent-file");
    decodeMaget('magnet:?xt=urn:btih:cc7aa890d03cb495a6e51901b5807ef384d29a5d&tr=http%3a%2f%2ft.nyaatracker.com%2fannounce&tr=http%3a%2f%2ftracker.kamigami.org%3a2710%2fannounce&tr=http%3a%2f%2fshare.camoe.cn%3a8080%2fannounce&tr=http%3a%2f%2fopentracker.acgnx.se%2fannounce&tr=http%3a%2f%2fanidex.moe%3a6969%2fannounce&tr=http%3a%2f%2ft.acg.rip%3a6699%2fannounce&tr=https%3a%2f%2ftr.bangumi.moe%3a9696%2fannounce&tr=udp%3a%2f%2ftr.bangumi.moe%3a6969%2fannounce&tr=http%3a%2f%2fopen.acgtracker.com%3a1096%2fannounce&tr=udp%3a%2f%2ftracker.opentrackr.org%3a1337%2fannounce');
    // parseTorrentFile();
}
)()
